#include<stdio.h>
int main()
{
    int m,n,i,j,x;
    scanf("%d",&n);
    int shuzu[n-1];
    for(i=0;i<n;i++)
    {
        scanf("%d",&shuzu[i]);
    }
    scanf("%d",&m);
    for(i=1;i<=m;i++)
    {
        int cnt=0;
        scanf("%d",&x);
        for(j=0;j<n;j++)
        {
           
            if(n==2)
            {
                if(x==shuzu[0]) 
                {
                    printf("%d\n",shuzu[1]);
                    cnt++;
                }
            
                else if(x==shuzu[1]) 
                {
                    printf("%d\n",shuzu[0]);
                    cnt++;
                }
                
            }
            if(shuzu[j]==x&&n!=1&&n!=2)
            {
              if(j==0) printf("%d\n",shuzu[1]);
              else if(j==(n-1)) printf("%d\n",shuzu[j-1]);
              else printf("%d %d\n",shuzu[j-1],shuzu[j+1]);
              cnt++;
            }
        }
        if(cnt==0) printf("NULL\n");
    }
}